class MyQueue:

    def __init__(self):
        """
        Initialize your data structure here.
        """
        self.lstack=[]
        self.rstack=[]


    def push(self, x: int) -> None:
        """
        Push element x to the back of queue.
        """
        self.lstack.append(x)

    def pop(self) -> int:
        """
        Removes the element from in front of queue and returns that element.
        """
        if len(self.rstack)!=0:
            return self.rstack.pop()
        else:
            for i in range(len(self.lstack)):
                self.rstack.append(self.lstack.pop())
            return self.rstack.pop()


    def peek(self) -> int:
        """
        Get the front element.
        """
        if len(self.rstack)!=0:
            return self.rstack[-1]
        else:
            for i in range(len(self.lstack)):
                self.rstack.append(self.lstack.pop())
            return self.rstack[-1]

    def empty(self) -> bool:
        """
        Returns whether the queue is empty.
        """
        return len(self.lstack)==0 and len(self.rstack)==0



# Your MyQueue object will be instantiated and called as such:
# obj = MyQueue()
# obj.push(x)
# param_2 = obj.pop()
# param_3 = obj.peek()
# param_4 = obj.empty()


'''
执行用时：
28 ms
, 在所有 Python3 提交中击败了
99.37%
的用户
内存消耗：
14.9 MB
, 在所有 Python3 提交中击败了
5.55%
的用户
'''